<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>	
<%@ include file="/pub/headmeta.jsp" %>
</head>
<body>
	<div class="right-head"><span class="right-head-font">指标数据查询</span></div>
	
	<form id="queryForm" method="post">
	<div class="term">
		<div class="div1-2">主题名称：</div>
		<div class="div2"><input type="text" name="q_titleName" id="q_titleName"/></div>
		<div class="div1-2">上传时间：</div>
		<div class="div2"><input type="text" name="q_uploadTime" id="q_uploadTime"  class="Wdate" onClick="WdatePicker()"/></div>
		<br style="clear:both;" /><br />
	</div>
	<div class="function-bar">
		<div class="div0"><input  type="button" class="button-bar" value="重置条件" onclick="resetEx(this.form);"/></div>
		<div class="div0"><input  type="button" class="button-bar" value="查询" onclick="setCurPage(1);doQuery();"/></div>
		<div class="div0"><input  type="button" class="button-bar" value="删除" onclick="doDel();" ${f:op(ops,'指标数据查询','删除')}/></div>
		<div class="div0"><input  type="button" class="button-bar" value="导入" onclick="viewImport();" ${f:op(ops,'指标数据查询','导入')}/></div>
	</div>	
	</form>
	
	<form id="delForm" method="post">
	<table id="MyTableList" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table-form">
		<tr align="center" class="STYLE1">			
			<th width="5%">序号</th>
			<th width="20%">主题名称</th>
			<th width="20%">上传批次说明</th>
			<th width="20%">上传者</th>
			<th width="20%">上传时间</th>			
			<th width="15%">操作</th>	
		</tr>
	</table>
	<%@ include file="/pub/pageLink.jsp" %>
	</form>	
</body>
</html>
<script type="text/javascript">
<!--
//自动调用初始化
$(document).ready(function(){	
	//查询
	doQuery();
});
var listData;//记录当前页数据
//查询
function doQuery(){	
	var page=getPage();
	var pageSize=getPageSize();
	var url="${ctx}/title!getList.action?page="+page+"&pageSize="+pageSize;
	$.post(url, $("#queryForm").serialize() ,function callback(txt){   
			var json = $.parseJSON(txt);
			if (json.code==0) {	
				setRecordCount(json.count);
				listData=json.info;
				createTable(listData,page,pageSize);				
			}else{
				alert('查询失败！');
			}
		}	
	);
	$('#ckAll').attr("checked",false);
}

//删除
function doDel(){
	if ($("#q_uploadTime").val()== ""){
		alert('请选择查询条件[上传时间]作为批次删除！');
		return;
	}	
	if(confirm('确定要删除'+$("#q_uploadTime").val()+'上传的记录吗？')){
		var url="${ctx}/title!remove.action";
		$.post(url, $("#queryForm").serialize() ,function callback(txt){   
				var json = $.parseJSON(txt);
				if (json.code==0) {	
					document.getElementById("q_uploadTime").value="";
					doQuery();			
				}else{
					alert('删除失败！');
				}
			}	
		);			
	}

}

//创建表数据
function createTable(objs,page,pageSize){	
	var table=document.getElementById('MyTableList');
	for( var i=table.rows.length-1; i>0; i--){
		table.deleteRow(i); 
	}
	var b=document.createElement("tbody");
	for(var i=0;i<objs.length;i++){
		var obj=objs[i];
		var row=document.createElement("tr");	
		row.align="center";	
		
		var c1=document.createElement("td");	
		c1.innerHTML=(page-1)*pageSize+i+1;
		var c2=document.createElement("td");	
		c2.innerHTML=obj.titleName;
		var c3=document.createElement("td");	
		c3.innerHTML=obj.note;
		var c4=document.createElement("td");	
		c4.innerHTML=obj.creator;
		var c5=document.createElement("td");	
		c5.innerHTML=formatDate(obj.createTime);
		var c6=document.createElement("td");	
		c6.innerHTML="<a class='edit-font' href=\"javascript:viewDetail('"+obj.titleId+"');\">查看指标树</a>";

		row.appendChild(c1);
		row.appendChild(c2);
		row.appendChild(c3);
		row.appendChild(c4);
		row.appendChild(c5);
		row.appendChild(c6);
		
		setTdStyle(row);
		b.appendChild(row);
	}
	table.appendChild(b);
}
//查看指标树
function viewDetail(id){
	location.href="${ctx}/title!viewDetail.action?id="+id;
}
//导入
function viewImport(){
	location.href="${ctx}/title!viewImport.action";
}
//-->
</script>
